<?php
if( ! defined('BASEPATH')) exit('No direct script access allowed');

class allusers extends CI_Controller
{


	function __construct()
	{
		parent::__construct();
		// check if user logged in
		if(!$this->ion_auth->logged_in()){
			redirect('auth/login');
		}
		$this->load->library('form_validation');
		$this->load->model('user/allusers_model');
		
	}
	function users($id=null)
	{
		//$data['userid'] = $id;
		if(isset($id))
		{
			$user= $id;
		}else
		{
			$user=$this->session->userdata('user_id');		
		}
		$data['userid'] = $user;
		$data['users'] = $this->allusers_model->users_getall();
		$data['designation'] = $this->allusers_model->usertype_getall();

		$meta['page_title'] = "All Users";
		$this->load->view('common/header',$meta);
		$this->load->view('user/allusers',$data);
		$this->load->view('common/footer');

	}
	
	function team($id=null)
    {
		//$data['userid'] = $id;
		if(isset($id))
		{
			$user= $id;
		}else
		{
			$user=$this->session->userdata('user_id');		
		}
	   //list the users
	  	$this->data['userid'] = $user;
		$this->data['user'] = $this->allusers_model->users_getall();
		$this->data['users'] = $this->allusers_model->get_employees();
		$this->data['developers'] = $this->allusers_model->count_developers();
		$this->data['designers'] = $this->allusers_model->count_designers();
		$this->data['content_writers'] = $this->allusers_model->count_content_writers();
		//$this->data['department'] = $this->allusers_model->count_department();
			
			//print_r($this->data['users']);exit;
		foreach ($this->data['users'] as $k => $user)
		{
			$this->data['users'][$k]->groups = $this->ion_auth->get_users_groups($user->id)->result();
		}
	
	 	foreach ($this->data['users'] as $l => $user)
			{
				$this->data['users'][$l]->user_type = $this->ion_auth->get_user_type($user->id)->result();
			}
			
		foreach ($this->data['users'] as $l => $user)
			{
				$this->data['users'][$l]->department = $this->ion_auth->get_user_department($user->id)->result();
			}

	   $meta['page_title'] = "Our Team";
	   $this->load->view('common/header', $meta);
	   $this->load->view('user/allusers',$this->data);
       $this->load->view('common/footer');
	   
   }
	
}